Skip to content

fix(store): guard findIndex(-1) in the data store actions - #3220

Open
AndyScherzinger wants to merge 1 commit into
mainfrom
fix/noid/data-store-findindex-guards
Open

AndyScherzinger wants to merge 1 commit into
mainfrom
fix/noid/data-store-findindex-guards

Conversation

@AndyScherzinger

Copy link
Copy Markdown
Member

Follow-up to #3219, which guarded the findIndex() results in src/store/store.js. The same bug is in src/store/data.js: updateColumn and updatePublicRow assign to columns[stateId][-1] / rows[stateId][-1] when the updated node is not in the local store, creating a bogus "-1" property that the getters never iterate over. A successful server call therefore left the store silently out of sync.

Both now use the map() that updateRow already uses one function over (data.js:362), which leaves the collection untouched when the id is absent. Raised as finding 4 of the review in #3219 (comment), which suggested keeping it out of that PR.

Pre-existing on main.

🖼️ Screenshots

n/a — no visual change (internal store guards only).

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed
  • 🔙 Backport requests are created or not needed: /backport to stableX.X
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

updateColumn and updatePublicRow assigned to columns[stateId][-1] and
rows[stateId][-1] when the updated node was not in the local store. That
creates a bogus "-1" property the getters never iterate over, so a
successful server call left the store silently out of sync instead of
either updating or ignoring the node.

Replace both with the map() that updateRow already uses, which leaves the
collection untouched when the id is absent.

Assisted-by: ClaudeCode:claude-opus-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants